__author__ = 'David'

from twitter.api import Twitter, TwitterError
from twitter.oauth import OAuth, write_token_file, read_token_file
from twitter.oauth_dance import oauth_dance

import os
import time
import sys

CONSUMER_KEY = 'uS6hO2sV6tDKIOeVjhnFnQ'
CONSUMER_SECRET = 'MEYTOS97VvlHX7K1rwHPEqVpTSqZ71HtvoK4sVuYk'

class Tweeter():
    def __init__(self):
        self.oauth_filename = os.environ.get('HOME', '') + os.sep \
            + '.twitter_oauth'
        self.oauth_token, self.oath_token_secret = \
            read_token_file(self.oauth_filename)
        try:
            self.poster = Twitter(
                auth=OAuth(self.oauth_token, self.oath_token_secret,
                       CONSUMER_KEY, CONSUMER_SECRET),
                secure=True,
                api_version='1',
                domain='api.twitter.com')
        except TwitterError:
            print TwitterError.message

    def Post(self, content):
        self.poster.statuses.update(status=content)
